package com.jr.service.impl;

import com.jr.dao.IUserDao;
import com.jr.dao.impl.UserDaoImpl;
import com.jr.pojo.User;
import com.jr.service.IUserService;

public class UserServiceImpl implements IUserService {

    private IUserDao iud = new UserDaoImpl();


    // 用户登录验证
    @Override
    public boolean login(String account, String password) {
        User user = iud.selectUserByAccount(account);
        if (user != null) {
            //user.getPassword()是根据用户输入的账号在库里查询的密码，password是用户输入的密码
            return user.getPassword().equals(password);
        }else{
            return false;
        }
    }



    // 根据账号获取管理员手机号
    @Override
    public String getAdminPhoneByAccount(String account) {
        User user1 = iud.selectUserByAccount(account);
        return user1 != null ? user1.getPhone() : null;
    }

    // 验证管理员姓名和身份证号
    @Override
    public boolean verifyAdminInfo(String account, String idcardName, String idcardNo) {
        return iud.checkAdminInfo(account, idcardName, idcardNo);
    }

    // 更新用户的企业ID和企业名称
    @Override
    public boolean updateUserEnterprise(String account, Integer enterpriseId, String enterpriseName) {
        int i = iud.updateUserEnterprise(account, enterpriseId, enterpriseName);
        return i > 0;
    }
    // 根据账号获取用户信息
    @Override
    public User getUserByAccount(String account) {
        return iud.selectUserByAccount(account);
    }
}
